package day05;

import java.util.Arrays;
import java.util.Random;

public class HomeWork {
    public static void main(String[] args) {
        //1. 两遍，数组的练习：访问、遍历、复制
        int[] arr={1,2,3,4,5,6,7,8,9,10};
        int[] w = new int[90];
        for (int i = 0; i < w.length; i++) {
            w[i] = (int) (Math.random() * 100);
            System.out.println(w[i]);

        }
        Random random = new Random();
        for (int i = 0; i < w.length; i++) {
            w[i] =random.nextInt(100);
            System.out.println(w[i]);

        }

        System.out.println(arr[7]);
        System.out.println(arr[5]);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        for(int i = 0; i < arr.length; i++){
            System.out.println(arr[i]);
        }
        int[] arr1 = new int[arr.length];
        for(int i = 0; i < arr.length; i++){
            arr1[i] = arr[i];
        }
        int[]c= Arrays.copyOf(arr,8);
        int[]c2 = Arrays.copyOf(arr1,11);

        //2. MaxOfArray求数组元素最大值
        int[]r=new int[]{w[0]};
        for(int i = 0;i<w.length;i++){
            if(r[0]<w[i]){
                r[0]=w[i];
            }
        }
        System.out.println("数组最大的值"+r[0]);

        int[]r1=new int[]{w[3]};
        for(int i = 0;i<w.length;i++){
            if(r1[0]<w[i]){
                r1[0]=w[i];
            }
        }
        System.out.println("数组最大的值"+r1[0]);
        //3. 方法的练习：
        /*- 要求：
        - 定义say()无参无返回值方法，调用测试
                - 定义say()有一个参无返回值方法，调用测试
                - 定义say()有两个参无返回值的方法，调用测试
                - 定义sum()两个参有返回值方法，调用测试
                - 定义generateArray()用于生成整型数组填充随机数并返回数组，调用测试
         */


        say("the");
        say("sky");
        say("is",5);
        say("the",5);
        int i = sum(98,34);
        i=sum(7,3);
        int[]ww=generateArray();
    }
    public static void say(String name){
        System.out.println("hello"+name);
    }
    public static void say(String name,int age){
        System.out.println("hello"+name+age);
    }
    public static int sum(int num1, int num2) {
       int sumw = num1 + num2;
       return sumw;
    }
    public static int[] generateArray() {
        int[] arr = new int[10];
        //Random random = new Random();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100);//arr[i] = random.nextInt(100);
        }
        return arr;
    }
}
